package com.icbc.open.chengdu.demo.account.scode;

import com.csii.pp.icbc.util.Util;
import com.icbc.api.DefaultIcbcClient;
import com.icbc.api.internal.util.internal.util.fastjson.JSON;
import com.icbc.api.request.SettlementAccountSCodeSendRequestV1;
import com.icbc.api.response.SettlementAccountSCodeSendResponseV1;
import com.icbc.open.chengdu.demo.BaseData;
import com.icbc.open.chengdu.demo.utils.SaveFileUtils;

/**
 * 验证码重发
 *
 * @author xcz
 */
public class SettlementAccountScodeSendTest {

    public static void main(String[] args) throws Exception {
        DefaultIcbcClient client = new DefaultIcbcClient(BaseData.APP_ID, BaseData.MY_RSA_PRIVATE_KEY, BaseData.ICBC_RSA_PUBLIC_KEY);
        SettlementAccountSCodeSendRequestV1 request = new SettlementAccountSCodeSendRequestV1();
        SettlementAccountSCodeSendRequestV1.SettlementAccountSCodeRequestV1Biz bizContent = new SettlementAccountSCodeSendRequestV1.SettlementAccountSCodeRequestV1Biz();
        request.setServiceUrl(BaseData.ACCOUNT_SCODE_SEND_URL);//API地址
        bizContent.setCorpDate(BaseData.TEST_CORP_DATE);//合作方工作日期
        bizContent.setCorpNo(BaseData.APP_ID);//合作方机构编号，我行分配的机构编号
        bizContent.setCorpSerno(Util.getNonceStr(16));//合作方交易单号
        bizContent.setCorpSernoOriginal(SaveFileUtils.getOpenAccount());//原合作方交易单号 开户
        //bizContent.setCorpSernoOriginal(SaveFileUtils.getCloseAccount());//原合作方交易单号 销户
        //bizContent.setCorpSernoOriginal(SaveFileUtils.getBindMedium());//原合作方交易单号 绑定
        bizContent.setOutServiceCode("1"); //外部服务代码
        bizContent.setTrxAccDate(BaseData.TEST_TRX_ACC_DATE); //合作方交易日期
        bizContent.setTrxAccTime(BaseData.TEST_TRX_ACC_TIME);//合作方交易时间
        request.setBizContent(bizContent);
        SettlementAccountSCodeSendResponseV1 response = client.execute(request);
        System.out.println(JSON.toJSONString(response));
        if (response.isSuccess() && response.getReturnCode() == 0) {
            //成功
        } else {
            //失败
        }

    }


}
